#ifndef __MACRO_H__
#define __MACRO_H__

#ifndef RGB
#define RGB(r, g, b)		[UIColor colorWithRed:(CGFloat)r/255.0 green:(CGFloat)g/255.0 blue:(CGFloat)b/255.0 alpha:1.0]
#endif

#ifndef RGBA
#define RGBA(r, g, b, a)		[UIColor colorWithRed:(CGFloat)r/255.0 green:(CGFloat)g/255.0 blue:(CGFloat)b/255.0 alpha:a]
#endif

#ifndef SAFE_RELEASE
#define	SAFE_RELEASE(ptr)	{if(ptr!=nil){[ptr release];ptr=nil;}}
#endif

#ifndef SAFE_DELETE
#define SAFE_DELETE(p) {if( p != NULL ){ delete p; p = NULL; }}
#endif

#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) {if( p != NULL ){ delete [] p; p = NULL; }}
#endif

#ifndef SAFE_FREE
#define SAFE_FREE(p) {if( p != NULL ){ free(p); p = NULL; }}
#endif

#ifndef SAFE_CLOSE
#define	SAFE_CLOSE(file)	if(file!=NULL) {fclose(file);file=NULL;}
#endif

#ifndef SAFE_RELEASE_TIMER
#define	SAFE_RELEASE_TIMER(timer)	if(timer!=NULL) {[timer invalidate]; timer = nil;}
#endif

#endif